// ============================== 导入依赖 ============================== //

import UTIL from '@admin/views/Monitor/Elec/UTIL'

const TIME = ['时间', 'time', '']

// ============================== 导出计算属性 ============================== //

export default {
  /**
   * 自定义计算属性 (可覆盖)
   */
  GETTER: ({ DICT, list }) => ({
    // 电压表格
    tableV: {
      rows: [TIME, ...DICT.FIELD_V],
      list: UTIL.transFieldList(list, DICT.FIELD_V),
    },

    // 电流表格
    tableA: {
      rows: [TIME, ...DICT.FIELD_A],
      list: UTIL.transFieldList(list, DICT.FIELD_A),
    },

    // 电压图表
    chartV: {
      xData: list.map((row) => row.date),
      dataList: DICT.FIELD_V.map(([, field]) => list.map((item) => item[field])),
      dataNames: DICT.FIELD_V.map(([name]) => name),
      dataUnits: DICT.FIELD_V.map(([, , unit = '']) => unit),
    },

    // 电流图表
    chartA: {
      xData: list.map((row) => row.date),
      dataList: DICT.FIELD_A.map(([, field]) => list.map((item) => item[field])),
      dataNames: DICT.FIELD_A.map(([name]) => name),
      dataUnits: DICT.FIELD_A.map(([, , unit = '']) => unit),
    },
  }),
}
